home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / etc / cron.weekly / sysklogd < prev   
Encoding:
Text File  |  2009-01-23  |  1.2 KB  |  47 lines

  1. #! /bin/sh
  2.  
  3. # sysklogd    Cron script to rotate system log files weekly.
  4. #
  5. #        If you want to rotate logfiles daily, edit
  6. #        this script and /etc/cron.daily/sysklogd to get
  7. #        the logfiles in sync (they must not occur in both
  8. #        files).
  9. #
  10. #        This is a configration file.  You are invited to edit
  11. #        it and maintain it on your own.  You'll have to do
  12. #        that if you don't like the default policy
  13. #        wrt. rotating logfiles (i.e. with large logfiles
  14. #        weekly and daily rotation may interfere).  If you edit
  15. #        this file and don't let dpkg upgrade it, you have full
  16. #        control over it.  Please read the manpage to
  17. #        syslogd-listfiles.
  18. #
  19. #        Written by Ian A. Murdock <imurdock@debian.org>.
  20. #        $Id: cron.weekly,v 1.11 2007-05-28 16:33:34 joey Exp $
  21.  
  22. test -x /usr/sbin/syslogd-listfiles || exit 0
  23. test -x /sbin/syslogd || exit 0
  24. test -f /usr/share/sysklogd/dummy || exit 0
  25.  
  26. set -e
  27.  
  28. USER=$(ps -C syslogd -o user= | head -n 1)
  29. [ -z "${USER}" ] && USER="root" || true
  30.  
  31. cd /var/log
  32.  
  33. logs=$(syslogd-listfiles --weekly)
  34.  
  35. test -n "$logs" || exit 0
  36.  
  37. for LOG in $logs
  38. do
  39.    if [ -s $LOG ]; then
  40.       savelog -g adm -m 640 -u ${USER} -c 4 $LOG >/dev/null
  41.    fi
  42. done
  43.  
  44. # Restart syslogd
  45. #
  46. /etc/init.d/sysklogd reload-or-restart > /dev/null
  47.